package tools;

import java.sql.SQLException;
import java.util.Map;

import com.google.gson.Gson;

import Serverlet.CommoServlet;
import Serverlet.OrderServlet;
import Serverlet.Userservlet;

/**
 * 中转站

 */

public  class Transfer {
	
    public String transfer(String request){  
    	Gson gson=new Gson();
        Map map = gson.fromJson(request, Map.class);
        String cmd=(String) map.get("cmd");

        
        if(cmd.equals("register")){
        	return new Userservlet().register(request);
        }else if(cmd.equals("login")){
        	return new Userservlet().login(request);
        }else if(cmd.equals("get_type")) {
        	return new CommoServlet().listCommo(request);
        }
        else if(cmd.equals("get_reco")){
        	return new OrderServlet().forward(request);
        }
        else if(cmd.equals("pay")) {
        	try {
				return new OrderServlet().pay(request);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        }
        else if(cmd.equals("order")) {
        	return new OrderServlet().order(request);
        }
        
       
        
        return "false";  
    }
}
